package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-02
 * Time: 14:27
 */
public class TestDemo {

    /**
     * 有三个线程，线程名称分别为：a，b，c。
     * 每个线程打印自己的名称。
     * 需要让他们同时启动，并按 c，b，a的顺序打印
     */
    public static void main(String[] args) throws InterruptedException {
        Thread c = new Thread(()->{
            System.out.println(Thread.currentThread().getName());
        },"c");
        c.start();
        Thread b = new Thread(()->{
            try {
                c.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
        },"b");
        b.start();
        Thread a = new Thread(()->{
            try {
                b.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
        },"a");
        a.start();

    }


}
